import request from "@/utils/request"
const commonPath = "/admin/product";
const SPU = {
  //根据三级分类获取基础属性列表 GET /admin/product/{page}/{limit}?category3Id=61
  getSPUList:function ({page,limit,category3Id}){
    return request.get(`${commonPath}/${page}/${limit}`,{
      params:{category3Id}
    })
  },

  //获取所有的品牌列表 GET /admin/product/baseTrademark/getTrademarkList
  getBaseTrademark:function (){
    return request.get(`${commonPath}/baseTrademark/getTrademarkList`)
  },

  //获取对应spu的图片列表 GET /admin/product/spuImageList/{spuId}
  getSpuImageList:function (spuId){
    return request.get(`${commonPath}/spuImageList/${spuId}`)
  },

  //获取对应spu的销售属性  GET /admin/product/spuSaleAttrList/{spuId}
  getSpuSaleAttrList:function (spuId){
    return request.get(`${commonPath}/spuSaleAttrList/${spuId}`)
  },

  //获取所有的销售属性 GET /admin/product/baseSaleAttrList
  getBaseSaleAttrList:function (){
    return request.get(`${commonPath}/baseSaleAttrList`)
  },

  //新增&修改spu  POST /admin/product/saveSpuInfo  POST /admin/product/updateSpuInfo
  addOrUpdateSpu:function (spuInfo){
    if(spuInfo.id){
      return request.post(`${commonPath}/updateSpuInfo`,{
        ...spuInfo
      })
    }else{
      //必须要带category3Id!!!!
      return request.post(`${commonPath}/saveSpuInfo`,{
        ...spuInfo
      })
    }
  },

  //删除spu DELETE /admin/product/deleteSpu/{spuId}
  deleteSpu:function(spuId){
    return request.delete(`${commonPath}/deleteSpu/${spuId}`)
  }
}

export default SPU

